-- POCOR-2785
-- system_patches
INSERT INTO `system_patches` (`issue`, `created`) VALUES('POCOR-2785', NOW());

-- translations
INSERT INTO `translations` (`en`, `editable`, `created_user_id`, `created`) VALUES ('%tree_no_of_item items selected', 1, 1, NOW());


-- POCOR-3646
-- system_patches
INSERT INTO `system_patches` (`issue`, `created`) VALUES ('POCOR-3646', NOW());

-- security_users
UPDATE `security_users`
SET `username` = `openemis_no`
WHERE `username` IS NULL;

ALTER TABLE `security_users`
CHANGE COLUMN `username` `username` VARCHAR(100) NOT NULL ;

UPDATE `security_functions` SET `_add`='StudentUser.add|getUniqueOpenemisId|getAutoGeneratedPassword' WHERE `id`=1043;
UPDATE `security_functions` SET `_add`='StaffUser.add|getUniqueOpenemisId|getAutoGeneratedPassword' WHERE `id`=1044;

ALTER TABLE `system_errors`
CHANGE COLUMN `code` `code` INT(5) NULL;


-- POCOR-4025
-- db_patches
INSERT INTO `system_patches` (`issue`, `created`) VALUES('POCOR-4025', NOW());

-- education_grades_subjects
ALTER TABLE `education_grades_subjects` CHANGE `hours_required` `hours_required` DECIMAL(5,2) NULL;


-- 3.10.3
UPDATE config_items SET value = '3.10.3' WHERE code = 'db_version';
UPDATE system_patches SET version = (SELECT value FROM config_items WHERE code = 'db_version') WHERE version IS NULL;
SET @maxId := 0;
SELECT max(id) + 1 INTO @maxId FROM system_updates;
INSERT IGNORE INTO system_updates (id, version, date_released, date_approved, approved_by, status, created) VALUES
(
  @maxId,
  (SELECT value FROM config_items WHERE code = 'db_version'),
  NOW(), NOW(), 1, 2, NOW()
);
